<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
  <h2>index page</h2>
  <button onclick="getMessage()">按我执行ajax动作</button>
    <span id = "result"></span>
</div>

<!--<script src="https://unpkg.com/axios/dist/axios.min.js"></script>-->
<script src="/js/axios.min.js"></script>

<script>
    function getMessage(){
        //基于ajax发送异步请求
        let url = "http://localhost:9000/nacos/provider/echo/1"
        axios.get(url)
            .then(function (response){
                console.log(response);
                //将获取到的响应数据展现到网站上
                let span = document.getElementById("result");
                if(response.data.code == 429){
                    span.innerHTML = response.data.msg;
                }else {
                    span.innerHTML = response.data;
                }
            })
            .catch(function (error){
                console.log(error);
            });
    }
</script>
</body>
</html>